de.ueberdosis.mp3info.id3v2
Class Helper

java.lang.Object
  |
  +--de.ueberdosis.mp3info.id3v2.Helper
All Implemented Interfaces:
Defines

public class Helper
extends java.lang.Object
implements Defines

Provides some functionality that is necessary for decoding ID3v2


Field Summary
 
Fields inherited from interface de.ueberdosis.mp3info.Defines
DEFAULT_ENCODING, ID3V2_FOOTER_SIZE, ID3V2_FRAME_HEADER_SIZE, ID3V2_HEADER_SIZE, ID3V2_X_HEADER_SIZE, MP3_FRAME_HEADER_SIZE, SUPPORTED_NUMBER_OF_EXTENDED_FLAG_BYTES, testPositions, VERSION
 
Constructor Summary
Helper()
           
 
Method Summary
static java.lang.String arrayToHexString(byte[] bAr)
          converts a byte array to a Hex string.
static java.lang.String byteToHexString(byte b)
          converts a byte to a Hex string
static java.lang.String byteToHexString(int i)
          Converts an unsigned int-wrapped byte to a Hex String i.e.
static int byteToUnsignedInt(byte b)
          converts a byte to an unsigned int
static int decodeBytesToInt(byte[] bAr)
           
static long pow(long number, long exp)
           
static byte[] reallocateByteBuffer(int size, byte[] oldBuffer)
          creates a new byte array as buffer
static byte[] synchsafe(long value, int length)
          creates a number of synchsafe bytes from a long
static byte unsignedIntToByte(int i)
          converts an unsigned int (between 0 and 255) to a byte any value out of range will result in -128!!!
static long unsynchsafe(byte[] b)
          creates a long from a number of synchsafe bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Helper

public Helper()
Method Detail

unsynchsafe

public static long unsynchsafe(byte[] b)
creates a long from a number of synchsafe bytes. A synchsafe byte has its highest bit zeroed. In accordance to the ID3V2-standard the byte-order is MSB first.

Parameters:
b - any number of bytes together denoting a number not bigger than can be stored in a long.
Returns:
the integer contained in the byte-array (or an erroneous number if too many bytes were supplied).

synchsafe

public static byte[] synchsafe(long value,
                               int length)
creates a number of synchsafe bytes from a long

Parameters:
value - a value.. Sensibly one that fits into the given number of bytes
length - number of bytes to create.
Returns:
the array containing the snychsafed value

pow

public static long pow(long number,
                       long exp)

decodeBytesToInt

public static int decodeBytesToInt(byte[] bAr)

arrayToHexString

public static java.lang.String arrayToHexString(byte[] bAr)
converts a byte array to a Hex string. With a line by Andreas Mandel at sourceforge (thanks!).


byteToHexString

public static java.lang.String byteToHexString(byte b)
converts a byte to a Hex string


byteToHexString

public static java.lang.String byteToHexString(int i)
Converts an unsigned int-wrapped byte to a Hex String i.e. the int must be between 0 and 255. if the int is out of range, an error string is returned


byteToUnsignedInt

public static int byteToUnsignedInt(byte b)
converts a byte to an unsigned int


unsignedIntToByte

public static byte unsignedIntToByte(int i)
converts an unsigned int (between 0 and 255) to a byte any value out of range will result in -128!!!


reallocateByteBuffer

public static byte[] reallocateByteBuffer(int size,
                                          byte[] oldBuffer)
creates a new byte array as buffer

Parameters:
size - number of bytes the new buffer should be bigger than the old
oldBuffer - old Buffer
Returns:
new Buffer with size = size + oldBuffer.length
null if an error occured;